package trivia;

import javax.swing.ButtonGroup;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.Dimension;
import javax.swing.JRadioButton;
import java.awt.Rectangle;
import javax.swing.JButton;

@SuppressWarnings("serial")
public class ChooseLevelFrame extends JFrame {

	private JFrame jChooseLFrame = null;  //  @jve:decl-index=0:visual-constraint="173,39"
	private JPanel jChooseLContentPane = null;
	private JRadioButton jNormalRadioButton = null;
	private JRadioButton jEasyRadioButton = null;
	private JRadioButton jHardRadioButton = null;
	private ButtonGroup levelGroup = new ButtonGroup();  //  @jve:decl-index=0:
	private JButton jOkButton = null;
	private JButton jCancelButton = null;
	public int level = -1; // 0 easy, 1 normal y 2 hard
	
	@SuppressWarnings("unused")
	private NewGame game;
	
	public ChooseLevelFrame () {
		jChooseLFrame = getJChooseLFrame();
		jNormalRadioButton.setSelected(true);
		jChooseLFrame.setVisible(true);
	}

	/**
	 * This method initializes jChooseLFrame	
	 * 	
	 * @return javax.swing.JFrame	
	 */
	public JFrame getJChooseLFrame() {
		if (jChooseLFrame == null) {
			jChooseLFrame = new JFrame();
			jChooseLFrame.setSize(new Dimension(300, 165));
			jChooseLFrame.setTitle("Choose level");
			jChooseLFrame.setContentPane(getJChooseLContentPane());
		}
		return jChooseLFrame;
	}

	/**
	 * This method initializes jChooseLContentPane	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJChooseLContentPane() {
		if (jChooseLContentPane == null) {
			jChooseLContentPane = new JPanel();
			jChooseLContentPane.setLayout(null);
			jChooseLContentPane.add(getJEasyRadioButton(), null);
			jChooseLContentPane.add(getJNormalRadioButton(), null);
			jChooseLContentPane.add(getJHardRadioButton(), null);
			jChooseLContentPane.add(getJCancelButton(), null);
			jChooseLContentPane.add(getJOkButton(), null);
			levelGroup.add(jEasyRadioButton);
			levelGroup.add(jNormalRadioButton);
			levelGroup.add(jHardRadioButton);
			//levelGroup.setSelected((ButtonModel) jNormalRadioButton, true);
		}
		return jChooseLContentPane;
	}

	/**
	 * This method initializes jNormalRadioButton	
	 * 	
	 * @return javax.swing.JRadioButton	
	 */
	private JRadioButton getJNormalRadioButton() {
		if (jNormalRadioButton == null) {
			jNormalRadioButton = new JRadioButton();
			jNormalRadioButton.setText("Normal");
			jNormalRadioButton.setBounds(new Rectangle(110, 45, 100, 25));
		}
		return jNormalRadioButton;
	}

	/**
	 * This method initializes jEasyRadioButton	
	 * 	
	 * @return javax.swing.JRadioButton	
	 */
	private JRadioButton getJEasyRadioButton() {
		if (jEasyRadioButton == null) {
			jEasyRadioButton = new JRadioButton();
			jEasyRadioButton.setText("Easy");
			jEasyRadioButton.setBounds(new Rectangle(0, 45, 100, 25));
		}
		return jEasyRadioButton;
	}

	/**
	 * This method initializes jHardRadioButton	
	 * 	
	 * @return javax.swing.JRadioButton	
	 */
	private JRadioButton getJHardRadioButton() {
		if (jHardRadioButton == null) {
			jHardRadioButton = new JRadioButton();
			jHardRadioButton.setText("Hard");
			jHardRadioButton.setBounds(new Rectangle(220, 45, 100, 25));
		}
		return jHardRadioButton;
	}

	/**
	 * This method initializes jOkButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	public JButton getJOkButton() {
		if (jOkButton == null) {
			jOkButton = new JButton();
			jOkButton.setText("Ok");
			jOkButton.setBounds(new Rectangle(200, 90, 90, 30));
			
		}
		return jOkButton;
	}

	/**
	 * This method initializes jCancelButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJCancelButton() {
		if (jCancelButton == null) {
			jCancelButton = new JButton();
			jCancelButton.setText("Cancel");
			jCancelButton.setBounds(new Rectangle(100, 90, 90, 30));
			jCancelButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					jChooseLFrame.dispose();
				}
			});
		}
		return jCancelButton;
	}
		
	public boolean isEasySelected () {
		return jEasyRadioButton.isSelected();
	}
	
	public boolean isNormalSelected () {
		return jNormalRadioButton.isSelected();
	}
	
	public boolean isHardSelected () {
		return jHardRadioButton.isSelected();
	}

}
